const merge = require('webpack-merge')
const common = require('./webpack.common.js')
const StyleLintPlugin = require('stylelint-webpack-plugin');
const path = require('path');
// webpack.common中，如果采用的是直接返回对象的形式，那么common后面就不需要括号
module.exports = merge(common, {
  mode: 'development',
  devtool: 'inline-source-map',
  devServer: {
    contentBase: './dist',
    hot: true
  },
  module: {
    rules:[
      {
        // 引入eslint，配置文件在eslintrc.js中，设置formatter和自动修复
        enforce: 'pre',
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'eslint-loader',
        options: {
          formatter: require('eslint-friendly-formatter'),
          fix: true
        }
      }
    ]
  },
  // 引入csslint
  plugins: [
    new StyleLintPlugin({
        files: ['**/*.less', '**/*.scss', '**/*.css'],
        // files: '(**/*.less|**/*.scss)',
        failOnError: false,
        quiet: true,
        fix: true
    }),
  ]
})
